package com.yellow.orderservice.controller;

import com.yellow.orderservice.entity.Order;
import com.yellow.orderservice.entity.Receiver;
import com.yellow.orderservice.service.ReceiverService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: hy
 * @create: 2024-04-25
 */

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/recv")
@Slf4j
public class ReceiverController {

    @Resource
    private ReceiverService receiverService;
    @RequestMapping("/getReceiverByName/{name}")
    public List<Receiver> getReceiverByName(@PathVariable("name") String name){
        return receiverService.findReceiverByName(name);
    }

    @RequestMapping("/getOrdersByReceiverName/{name}")
    public List<Order> getOrdersByReceiverName(@PathVariable(value = "name") String name){
        return receiverService.getOrdersByReceiverName(name);
    }
}
